const express = require('express');
const router = express.Router();
const { test } = require('../controllers/test');
const { loginWX, getUserInfo, updateUserInfo, login, register, editUserRole, getAllUsers } = require('../controllers/user');
const { createPostItem, getPostItems, getPostItemById, deletePostItemById, updatePostItemStatu, getPostItemByUserId, getAllPostItems, getPostItemByPostType,getPostItemsCount, } = require('../controllers/postItem');
const { createComment, getCommentsByCommentId, getCommentsByPostId, deleteComment } = require('../controllers/comment');
const { applyClub, /* applyClubTeacher ,*/ getTeacherByClubId, getImgByClubId, getClubList, passClub, joinClub, checkJoin, getClubDetail, getClubJoinPlz, getClubByUserId, updateClub } = require('../controllers/club');
const { upload, uploadFileLocal } = require('../controllers/document')
// const { uploadFile } = require('../controllers/oss');
router.get('/test', test);

router.post('/wxLogin', loginWX)
router.get('/userInfo', getUserInfo)
router.post('/userInfo', updateUserInfo)
router.post('/login', login)
router.post('/register', register)
router.post('/editUserRole', editUserRole)
router.get('/getAllUsers', getAllUsers)

router.post('/newPost', createPostItem)
router.post('/getPostItems', getPostItems)
router.get('/getPostItemById', getPostItemById)
router.delete('/deletePostItemById', deletePostItemById)
router.post('/updatePostItemStatu', updatePostItemStatu)
router.post('/getPostItemByUserId', getPostItemByUserId)
router.post('/getAllPost', getAllPostItems)
router.get('/getPostItemsCount', getPostItemsCount)


//评论
router.post('/newComment', createComment)
router.get('/getCommentsByCommentId', getCommentsByCommentId)
router.get('/getCommentsByPostId', getCommentsByPostId)
router.delete('/deleteComment', deleteComment)


//社团
router.post('/applyClub', applyClub)
router.post('/getClubList', getClubList)
router.post('/passClub', passClub)
router.post('/joinClub', joinClub)
// router.post('/applyClubTeacher', applyClubTeacher)
router.post('/getClubJoinPlz', getClubJoinPlz)
router.post('/checkJoin', checkJoin)
router.post('/getClubDetail', getClubDetail)
router.post('/getClubByUserId', getClubByUserId)
router.get('/getTeacherByClubId', getTeacherByClubId)
router.post('/updateClub', updateClub)

// TODO 返回社团活动相关图片   做轮播图用？
router.get("/getImgByClubId", getImgByClubId)

// 单个文件上传
// router.post('/uploadFile', upload.single('file'), uploadFileLocal)
// 多个文件上传
router.post('/uploadFiles', upload.array('file', 9), uploadFileLocal)
module.exports = router;
